package com.fcscs.cservice.client.common.controller;

import java.util.Date;
import java.util.List;

import com.fcscs.core.common.SearchResultsContainer;
import com.fcscs.core.gwt.common.AsyncCallbackListener;
import com.fcscs.core.gwt.common.GWTAsyncCaller;
import com.fcscs.cservice.common.CServiceCommonEnums.BookingStatus;
import com.fcscs.cservice.common.CServiceCommonEnums.GuestProfileType;
import com.fcscs.cservice.domain.BookingBase;
import com.fcscs.cservice.domain.PropertyConfigRestaurant;
import com.fcscs.cservice.domain.Restaurant;
import com.fcscs.cservice.domain.RestaurantConfig;
import com.fcscs.cservice.domain.model.BookingIdAndMessage;
import com.fcscs.cservice.domain.model.BookingIdAndStatus;
import com.fcscs.cservice.domain.model.BookingUpdate;
import com.fcscs.cservice.domain.model.BookingView;
import com.fcscs.cservice.domain.model.NonInHouseGuestProfile;
import com.fcscs.cservice.domain.model.RestaurantConfigModel;
import com.fcscs.cservice.domain.model.RestaurantConfiguration;
import com.fcscs.cservice.gwt.client.BookingService;
import com.fcscs.cservice.gwt.client.BookingServiceAsync;
import com.fcscs.cservice.gwt.client.RestaurantService;
import com.fcscs.cservice.gwt.client.RestaurantServiceAsync;
import com.google.gwt.core.client.GWT;

public class BookingServiceController extends GWTAsyncCaller {

	private static BookingServiceController instance = new BookingServiceController();
	
	private BookingServiceAsync bkGWT =  GWT.create(BookingService.class);

	private RestaurantServiceAsync resGWT = GWT.create(RestaurantService.class);
	
	public static BookingServiceController getInstance() {
		return instance;
	}
	
	public void updateBookingStatus(long propId,List<BookingIdAndStatus> idstatus,AsyncCallbackListener<List<BookingIdAndMessage>> callback){
		bkGWT.updateBookingStatus(propId, idstatus, createCallBack(0,callback));
	}
	
	public void createBooking(BookingBase bkBase,NonInHouseGuestProfile nonInGuest,AsyncCallbackListener<BookingView> callback){
		bkGWT.createBooking(bkBase, nonInGuest, createCallBack(0,callback));
	}
	
	public void getRestaurantList(long orgId,Long propId,AsyncCallbackListener<List<Restaurant>> callback){
		resGWT.getRestaurants(orgId, propId,createCallBack(0,callback));
	}
	
	public void getBookingHistory(long propId,long guestId,int start,int resultCnt,AsyncCallbackListener<SearchResultsContainer<BookingView>> callback){
		bkGWT.getBookingHistory(propId, guestId, start, resultCnt, createCallBack(0,callback));
	}
	
	public void updateBooking(BookingUpdate bookingUpdate,AsyncCallbackListener<BookingView> callback){
		bkGWT.updateBooking(bookingUpdate, createCallBack(0, callback));
	}
	
	public void advancedFindBookings(long propId,Long restaurantId,String term,String firstName,String lastName,
			String mobileNo,GuestProfileType guestType,
			Date reservationDate,List<BookingStatus> statuses,Date startDate,Date endDate,int start,int resultCnt,
			AsyncCallbackListener<SearchResultsContainer<BookingView>> callback){
		bkGWT.findBookings(propId, restaurantId, term, firstName, lastName, mobileNo, guestType, reservationDate,
				statuses, startDate, endDate, start, resultCnt, null, true, createCallBack(0,callback));
	}
	
	public void simpleFindBookings(long propId,Long restaurantId,String term,Date reservationDate,int start,int resultCnt,AsyncCallbackListener<SearchResultsContainer<BookingView>> callback){
		bkGWT.simFindBookings(propId, restaurantId, term, reservationDate,start, resultCnt, createCallBack(0,callback));
	}
	
	public void saveRestaurantConfigModel(RestaurantConfigModel model,AsyncCallbackListener<RestaurantConfigModel> callback){
		resGWT.saveRestaurantConfigModel(model, createCallBack(0, callback));
	}
	
	public void getRestaurantConfigModel(long orgId,Long propId,AsyncCallbackListener<RestaurantConfigModel> callback){
		resGWT.getRestaurantConfigModel(orgId, propId, createCallBack(0,callback));
	}
	
	public void getRestaurantConfig(Long propId,long restaId,AsyncCallbackListener<List<RestaurantConfig>> callback){
		resGWT.getRestaurantConfig(propId, restaId, createCallBack(0, callback));
	}
	
	public void saveRestaurantConfig(RestaurantConfiguration resc,AsyncCallbackListener<RestaurantConfiguration> callback){
		resGWT.saveRestaurantConfig(resc, createCallBack(0, callback));
	}
	
	public void getPropertyConfigRestaurant(Long propId,AsyncCallbackListener<PropertyConfigRestaurant> callback){
		resGWT.getPropertyConfigRestaurant(propId,createCallBack(0,callback));
	}
	
	public void savePropertyConfigRestaurant(PropertyConfigRestaurant propConfigRest,AsyncCallbackListener<PropertyConfigRestaurant> callback){
		resGWT.savePropertyConfigRestaurant(propConfigRest,createCallBack(0,callback));
	}
}
